import type { DepartmentItem, GetPatientConsultOrderDetailData, GetPatientConsultOrderPreData, GetPatientConsultOrderPreParams, PostPatientConsultOrderParams, PostPatientConsultPayParams, RateParams } from '@/types/consult'
import { request } from '@/utils/request'

/**
 * 医生认证--查询所有科室-层级
 * @returns 所有科室
 */
export const getDepAllAPI = () => {
  return request<DepartmentItem[]>('/dep/all', 'GET')
}

/**
 * 问诊-保存/修改问诊订单
 * @param data 问诊订单数据
 * @returns 问诊订单id
 */
export const postPatientConsultOrderAPI = (data: PostPatientConsultOrderParams) => {
  return request<{ id: string }>('/patient/consult/order', 'POST', data)
}

/**
 * 问诊-支付页面-计算就诊信息和抵扣信息
 * @param params 参数
 * @returns 返回数据
 */
export const getPatientConsultOrderPreAPI = (params: GetPatientConsultOrderPreParams) => {
  return request<GetPatientConsultOrderPreData>('/patient/consult/order/pre', 'GET', params)
}


/**
 * 三方支付（暂时只支持支付宝支付）
 */
export const postPatientConsultPayAPI = (data: PostPatientConsultPayParams) => {
  return request<{ payUrl: string }>('/patient/consult/pay', 'POST', data)
}

/**
 * 问诊-查询订单详情信息-找医生、极速问诊和开药问诊
 * @param orderId 订单id
 * @returns 订单详情信息
 */
export const getPatientConsultOrderDetailAPI = (orderId: string) => {
  return request<GetPatientConsultOrderDetailData>('/patient/consult/order/detail', 'GET', {
    orderId,
  })
}

/**
 * 评价医生
 */
export const evaluateDoctorApi = (data:RateParams) => {
  return request('/patient/order/evaluate', 'POST', data)
}